<?php if(empty($r['order_info'])){ echo "亲，暂时还没有订单哦~"?>
<?php }else{?>
<form action="<?php e_qus(); ?>" method="get">
    <fieldset>
        <legend></legend>
        <label for="orderState">订单状态</label><br/>
        <select name="state" id="orderState">
            <option value="" >所有</option>
            <?php foreach($r['orderState'] as $k=>$v){ ?>
                <option value="<?=$k?>" <?php if($k==$r['currentState']) echo "selected";?>><?=$v?></option>
            <?php } ?>
        </select>
        <label for="orderId">订单ID</label><br/>
        <input type="text" id="orderId" placeholder="请输入订单ID" name="orderId"><br/>
        <label for="username">实际购买人联系方式</label><br/>
        <input type="text" id="username" placeholder="请输入实际购买人联系方式" name="username">
        <input type="submit" value="搜 索"/><br/><br/>
    </fieldset>
</form>
<table id="dataTable">
    <thead>
    <tr>
        <th>订单号</th>
        <th>当前状态</th>
        <th>下单/支付时间</th>
        <th>发货时间</th>
        <th>到站时间</th>
        <th>配送/通知时间</th>
        <th>价格</th>
        <th>操作</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <?php foreach($r['order_info'] as $v){?>
        <tr>
            <td><?php echo $v['id'];?></td>
            <td><?=$r['orderState'][$v['state']]; ?></td>
            <td>
                <?php if(!empty($v['payment_time'])){ ?>
                    <?=$v['payment_time']?>
                <?php } ?>
            </td>
            <td>
                <?php if(!empty($v['shipping_time'])){ ?>
                    <?=$v['shipping_time']?>
                <?php }elseif($v['state']=="unshipped"){ ?>
                    <a href="<?php e_action("dealUrgeShop","order_id=".$v['id'])?>">催一下商家</a>
                <?php } ?>
            </td>
            <td>
                <?php if(!empty($v['service_time'])){ ?>
                    <?=$v['service_time']?>
                <?php }elseif($v['state']=="shipped"){ ?>
                    <a href="<?php e_action("dealServiceReceive","order_id=".$v['id'])?>">点击记录到站时间</a>
                <?php } ?>
            </td>
            <td>
                <?php if(!empty($v['delivery_time'])){ ?>
                    <?=$v['delivery_time']?>
                <?php }elseif($v['state']=="service"){ ?>
                    <a href="<?php e_action("dealReceivedTime","order_id=".$v['id'])?>">点击记录用户签收时间</a>
                <?php } ?>
            </td>
            <td>总价：<?php echo $v['order_amount'];?>元（包含服务费）</td>
            <td><a href="<?php e_action("detail","order_id={$v['id']}")?>">查看对应订单</a></td>
            <td><?php if($v['state']=='evaluate'){?><a href="<?php e_page("comment","index","order_id={$v['id']}")?>">查看评价</a><?php }?></td>
        </tr>
    <?php } ?>
    </tbody>
</table>
<!--<table id="dataTable">-->
<!--    <thead>-->
<!--    <tr>-->
<!--        <th>订单号</th>-->
<!--        <th>当前状态</th>-->
<!--        <th>商家信息</th>-->
<!--        <th>订单金额</th>-->
<!--        <th>付款金额</th>-->
<!--        --><?php //foreach($r['order_info'] as $v){if($v['state']=='shipped'||$v['state']=='service'||$v['state']=='received'){?>
<!--            <th>操作</th>-->
<!--        --><?php //}?>
<!--        --><?php //}?>
<!--    </tr>-->
<!--    </thead>-->
<!--    <tbody>-->
<!--    --><?php //foreach($r['order_info'] as $v){?>
<!--        <tr>-->
<!--            <td>--><?php //echo $v['id'];?><!--</td>-->
<!--            <td>--><?php
//                switch($v['state']){
//                    case 'unpaid':echo "未付款";break;
//                    case 'unshipped':echo "未发货";break;
//                    case 'shipped':echo "已发货";break;
//                    case 'service':echo "等待服务站配送";break;
//                    case 'received':echo "用户已签收";break;
//                    case 'confirmed':echo "用户已确认";break;
//                    case 'refunding':echo "进入退货流程";break;
//                    case 'evaluate':echo "已评价";break;
//                    case 'assigned':echo "未知状态";break;
//                };
//                ?><!--</td>-->
<!--            <td>--><?php //echo $v['company'];?>
<!--            <td>--><?php //echo $v['order_amount'];?><!--</td>-->
<!--            <td>--><?php //echo $v['payment_amount'];?><!--</td>-->
<!--            <td>--><?php
//                switch($v['state']){
//                    case 'shipped' : ?><!--<a href="--><?php //e_action("shipped","id={$v['id']}");?><!--">商品到达服务站</a>--><?php //break;
//                    case 'service': ?><!--<a href="--><?php //e_action("received","id={$v['id']}");?><!--">用户已签收</a>--><?php //break;
//                    case 'received': ?><!--<a href="--><?php //e_action("confirmed","id={$v['id']}");?><!--">用户已确认</a>--><?php //break;
//                }?>
<!--            </td>-->
<!--        </tr>-->
<!--    --><?php //} ?>
<!--    </tbody>-->
<!--</table>-->
<?php
/** @var Page $page */
$page=$r['pages'];
?>
<?php echo $page->getPageHtml(); ?>
<?php }?>